﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="../Converter.xaml" />
    </ResourceDictionary.MergedDictionaries>
    <Style x:Key="BlackCheckBoxStyle" TargetType="{x:Type CheckBox}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CheckBox}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Image x:Name="CheckBoxImage" HorizontalAlignment="Left" VerticalAlignment="Center" 
									Stretch="Fill" Source="/Skins/Resource/Image/CheckBox-Unchecked.png" Width="18" Height="18" />
                        <ContentPresenter Grid.Column="1" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                            Content="{TemplateBinding Content}"
                                            Margin="{TemplateBinding Padding}"
                                            ContentTemplate="{TemplateBinding ContentTemplate}"
							                RecognizesAccessKey="True" 
							                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
							                VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="CheckBoxImage" Property="Source" Value="/Skins/Resource/Image/CheckBox-Checked.png" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="CheckBoxImage" Property="Opacity" Value="0.6" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="GreenCheckBoxStyle" TargetType="{x:Type CheckBox}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CheckBox}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Image x:Name="CheckBoxImage" HorizontalAlignment="Left" VerticalAlignment="Center" 
									Stretch="Fill" Source="/Skins/Resource/Image/GreenCheckBox-Unchecked.png" Width="17" Height="17" />
                        <ContentPresenter Grid.Column="1" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                            Content="{TemplateBinding Content}"
                                            Margin="{TemplateBinding Padding}"
                                            ContentTemplate="{TemplateBinding ContentTemplate}"
							                RecognizesAccessKey="True" 
							                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
							                VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="CheckBoxImage" Property="Source" Value="/Skins/Resource/Image/GreenCheckBox-Checked.png" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="CheckBoxImage" Property="Opacity" Value="0.6" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="TestItemCheckBox" TargetType="{x:Type CheckBox}">
        <Setter Property="IsChecked" Value="{Binding Tag.IsSelected, RelativeSource={RelativeSource Self}}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CheckBox}">
                    <Image x:Name="TestItemImage" Width="130" Height="130" 
                           Source="{Binding Tag.TestItemName, RelativeSource={RelativeSource TemplatedParent}, 
                        Converter={StaticResource TestItemDarkImageSourceConverter}}">
                        <Image.ToolTip>
                            <Label Width="140" Height="30" Content="{Binding Tag.TestItemTitle, RelativeSource={RelativeSource TemplatedParent}}" 
                                   HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="20" />
                        </Image.ToolTip>
                    </Image>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="TestItemImage" Property="Source" Value="{Binding Tag.TestItemName, RelativeSource={RelativeSource TemplatedParent}, 
                                Converter={StaticResource TestItemBrightImageSourceConverter}}" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="TestItemImage" Property="Source" Value="{Binding Tag.TestItemName, RelativeSource={RelativeSource TemplatedParent}, 
                                Converter={StaticResource TestItemBrightImageSourceConverter}}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="TestItemWithResultCheckBox" TargetType="{x:Type CheckBox}">
        <Setter Property="IsChecked" Value="{Binding Tag.NeedDetailReport, RelativeSource={RelativeSource Self}}" />
        <Setter Property="Content" Value="{Binding Tag.FormattedTestResult, RelativeSource={RelativeSource Self}}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type CheckBox}">
                    <StackPanel x:Name="TestItemContainer" Width="215" Height="60" Orientation="Horizontal" Margin="0,0,4,20">
                        <StackPanel.ToolTip>
                            <Label Width="140" Height="30" Content="{Binding Tag.TestItemTitle, RelativeSource={RelativeSource TemplatedParent}}" 
                                   HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="20" />
                        </StackPanel.ToolTip>
                        <Image x:Name="CheckBoxImage" Margin="0,0,5,0" Source="/Skins/Resource/Image/GreenCheckBox-Unchecked.png" Width="17" />
                        <Border x:Name="TestItemContainerBorder" Background="#6d6d6e" CornerRadius="4" Padding="3">
                            <StackPanel Orientation="Horizontal" Margin="-5,0,0,0">
                                <Image x:Name="TestItemImage" Height="50" Margin="5,0,0,0"
                                       Source="{Binding Tag.TestItemName, RelativeSource={RelativeSource TemplatedParent}, 
                                        Converter={StaticResource TestItemDarkImageSourceConverter}}">
                                </Image>
                                <Border Margin="2,0,10,0" Width="133" Height="50" Background="#dcdcdc">
                                    <TextBlock x:Name="TestResultTextBlock" FontSize="20" 
                                           Padding="10,12,0,0" Foreground="#153364"
                                           Text="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" 
                                           Tag="{Binding Tag.IsSelected, RelativeSource={RelativeSource TemplatedParent}}" />
                                </Border>
                            </StackPanel>
                            <interactivity:Interaction.Triggers>
                                <interactivity:EventTrigger EventName="MouseLeftButtonDown">
                                    <interactivity:InvokeCommandAction Command="{Binding DataContext.ShowSingleTestDetailCommand, ElementName=CurrentPage}" 
                                                                               CommandParameter="{Binding Tag, RelativeSource={RelativeSource TemplatedParent}}" />
                                </interactivity:EventTrigger>
                            </interactivity:Interaction.Triggers>
                        </Border>
                    </StackPanel>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="TestItemContainerBorder" Property="Background" Value="#6ac239" />
                            <Setter TargetName="CheckBoxImage" Property="Source" Value="/Skins/Resource/Image/GreenCheckBox-Checked.png" />
                            <Setter TargetName="TestItemImage" Property="Source" Value="{Binding Tag.TestItemName, RelativeSource={RelativeSource TemplatedParent}, 
                                Converter={StaticResource TestItemBrightImageSourceConverter}}" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="TestItemImage" Property="Source" Value="{Binding Tag.TestItemName, RelativeSource={RelativeSource TemplatedParent}, 
                                Converter={StaticResource TestItemBrightImageSourceConverter}}" />
                        </Trigger>
                        <DataTrigger Binding="{Binding Tag, ElementName=TestResultTextBlock}" Value="False">
                            <Setter TargetName="TestItemContainer" Property="Visibility" Value="Collapsed" />
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>